import requests

import unittest

"""
GET http://localhost/index.php?m=Home&c=User&a=verify&r=0.010405427673415124 HTTP

"""


class LoginTest(unittest.TestCase):

    def test_login(self):
        data = {
            "username": "18501218888",
            "password": "jiyun123456",
            "verify_code": "8888",
            "desc": "hello desc",
        }

        session = requests.Session()

        resp = session.get("http://localhost/index.php?m=Home&c=User&a=verify")
        # 会返回一个携带sessionID 的 cookie
        print(resp.cookies)

        # session 共用一个cookie，会自动携带 这个会话中的cookie 也就是携带了 sessionID的cookie
        resp = session.post("http://localhost/index.php?m=Home&c=User&a=do_login", data=data)

        print(resp.status_code)
        print(resp.json())


if __name__ == '__main__':
    unittest.main()
